use crate::{error::Error, modeling::workspace::ProjectApplicationTool};
use derive_builder::Builder;
use serde::{Deserialize, Serialize};

#[derive(Debug, Default, Serialize, Deserialize, Clone)]
pub enum AgentChatRequestMode {
    #[serde(rename = "streaming")]
    Streaming,
    #[default]
    #[serde(rename = "blocking")]
    Blocking,
}

#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
#[builder(name = "AgentChatRequestMessageBuilder")]
#[builder(pattern = "mutable")]
#[builder(setter(into, strip_option), default)]
#[builder(derive(Debug))]
#[builder(build_fn(error = "Error"))]
pub struct AgentChatRequestMessage {
    pub conversation_id: String,
    pub parent_message_id: Option<String>,
    pub files: Vec<String>,
    pub inputs: Vec<String>,
    pub query: String,
    pub response_mode: AgentChatRequestMode,
}

#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
#[builder(name = "AgentChatResponseMessageBuilder")]
#[builder(pattern = "mutable")]
#[builder(setter(into, strip_option), default)]
#[builder(derive(Debug))]
#[builder(build_fn(error = "Error"))]
pub struct AgentChatResponseMessage {
    pub limit: u32,
    pub has_more: bool,
    pub data: Vec<AgentChatResponseMessageItem>,
}

#[derive(Debug, Default, Serialize, Deserialize, Clone, Builder)]
#[builder(name = "AgentChatResponseMessageItemBuilder")]
#[builder(pattern = "mutable")]
#[builder(setter(into, strip_option), default)]
#[builder(derive(Debug))]
#[builder(build_fn(error = "Error"))]
pub struct AgentChatResponseMessageItem {
    pub id: String,
    pub conversation_id: String,
    pub inputs: Vec<String>,
    pub query: String,
    pub message: String,
    pub message_tokens: u32,
    pub answer: String,
    pub answer_tokens: u32,
    pub provider_response_latency: f32,
    pub workflow_run_id: Option<String>,
    pub message_files: Vec<String>,
    pub parent_message_id: Option<String>,
}
